package com.avengers.common.bean.enums.api.epp;

import com.avengers.core.bean.enums.DomainStatus;

/**
 * @author yu.wang
 * @since 2020-03-02 14:16
 **/
public enum ApiDomainStatus {
    /**
     * WAIT
     */
    WAIT(0, DomainStatus.WAIT),
    /**
     * SUCCESS
     */
    SUCCESS(1, DomainStatus.SUCCESS),
    /**
     * EXPIRE
     */
    EXPIRE(2, DomainStatus.EXPIRE),
    /**
     * REDEMPTION
     */
    REDEMPTION(3, DomainStatus.REDEMPTION),
    /**
     * VSP_WAIT
     */
    VSP_WAIT(4, DomainStatus.VSP_WAIT),
    /**
     * VSP_ING
     */
    VSP_ING(5, DomainStatus.VSP_ING),
    /**
     * VSP_FAIL
     */
    VSP_FAIL(10, DomainStatus.VSP_FAIL),
    /**
     * PASS_SEND
     */
    PASS_SEND(7, DomainStatus.OUT),
    /**
     * OUT
     */
    OUT(8, DomainStatus.OUT),
    /**
     * TRADE
     */
    TRADE(9, DomainStatus.TRADE),
    /**
     * PUSH
     */
    PUSH(6, DomainStatus.PUSH);

    public final Integer value;
    public final DomainStatus status;

    ApiDomainStatus(Integer value, DomainStatus status) {
        this.value = value;
        this.status = status;
    }

    @Override
    public String toString() {
        return this.value.toString();
    }

    public static ApiDomainStatus parse(DomainStatus domainStatus) {
        for (ApiDomainStatus apiDomainStatus : values()) {
            if (apiDomainStatus.status.equals(domainStatus)) {
                return apiDomainStatus;
            }
        }
        return ApiDomainStatus.SUCCESS;
    }

    public static ApiDomainStatus of(Integer value) {
        for (ApiDomainStatus apiDomainStatus : values()) {
            if (apiDomainStatus.value.equals(value)) {
                return apiDomainStatus;
            }
        }
        return null;
    }
}
